<?php
	//
	function array_search_r($needle, $haystack, $key_lookin='') {
		$path = NULL;
	    if (!empty($key_lookin) && array_key_exists($key_lookin, $haystack) && $needle === $haystack[$key_lookin]){
	    	$path[] = $key_lookin;
	    }else{
	        foreach($haystack as $key => $val) {
	            if (is_scalar($val) && $val === $needle && empty($key_lookin)) {
	            	$path[] = $key;
	            	break;
	            }else if(is_array($val) && $path = array_search_r($needle, $val, $key_lookin)){
	            	array_unshift($path, $key);
	            	break;
	            }
	        }
	    }
		return $path;
	}
	//
	// the function that will recursivly search an array. 
	function searchArrayRecursive($needle, $haystack){ 
		// loop through the haystack that has been passed in 
		foreach ($haystack as $key => $arr) { 
			// check to make sure that the element is an array 
			if(is_array($arr)) { 
				/* this is the tricky line, this will take the value 
				or $arr and call the function again each time 
				the function is called, $ret is set with the 
				return value of the function call, this builds 
				the string that get's returned. 
				*/
				$ret=searchArrayRecursive($needle, $arr); 
				/* check to make sure that the function call did 
				not return -1 and return the value of the $key and 
				the $ret 
				*/
				//
				if($ret!=-1) return $key.','.$ret; 
			} else { 
				/* check the array element and see if it matches the 
				search term. if it does, return the $key of the 
				element. 
				*/
				if($arr == $needle) return (string)$key; 
			} 
		} 
		// nothing was found, return -1 
		return -1; 
	} 
	//
?>